<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
    <title>Jumper</title>
    <link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>

<div id="container">

<div id="product">
	<div id="product_logo"></div>
	<div id="product_name"><big><b></b></big></div>
	<div id="product_description"></div>
</div> <!-- id="product" -->


<div id="main">


<!-- Menu -->

<div id="navigation">
<br/>
<h1>Jumper</h1>

<ul>
  <li><a href="../index.html">Index</a></li>
</ul>

<h2>Contents</h2>
<ul>
<li><a href="#Functions">Functions</a></li>
<li><a href="#Tables">Tables</a></li>
</ul>


<h2>Modules</h2>
<ul>
  <li><a href="../modules/core.bheap.html">core.bheap</a></li>
  <li><strong>core.grid</strong></li>
  <li><a href="../modules/core.heuristics.html">core.heuristics</a></li>
  <li><a href="../modules/core.node.html">core.node</a></li>
</ul>
<h2>Scripts</h2>
<ul>
  <li><a href="../scripts/init.html">init</a></li>
  <li><a href="../scripts/jumper.html">jumper</a></li>
</ul>

</div>

<div id="content">

<h1>Module <code>core.grid</code></h1>

<p><strong>The <code>grid</code> class API</strong>.</p>
<p> This file contains the implementation of a <a href="../modules/core.grid.html#core.grid">grid</a>  class, internally used by the
 search algorithm. The <a href="../modules/core.grid.html#core.grid">grid</a>  object is automatically generated upon initialization of the
 <code>pathfinder</code> object, passing it a mandatory <em>collision map</em>.
 During a search, the pathfinder evaluates <strong>costs values</strong> for each node being processed, in order to
 select, after each step of iteration, what node should be expanded next to reach the target
 optimally. Those values are cached within an array stored in the <a href="../modules/core.grid.html#core.grid">grid</a>  object.
 </p>
    <h3>Info:</h3>
    <ul>
        <li><strong>Copyright</strong>: 2012-2013</li>
        <li><strong>License</strong>: <a href="http://www.opensource.org/licenses/mit-license.php">MIT</a></li>
        <li><strong>Author</strong>: Roland Yonaba</li>
    </ul>


<h2><a href="#Functions">Functions</a></h2>
<table class="function_list">
	<tr>
	<td class="name" nowrap><a href="#grid:new">grid:new&nbsp;(map[, walkable[, processOnDemand]])</a></td>
	<td class="summary">Inits a new <a href="../modules/core.grid.html#core.grid">grid</a>  object</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#grid:isWalkableAt">grid:isWalkableAt&nbsp;(x, y)</a></td>
	<td class="summary">Checks walkability.</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#grid:getNeighbours">grid:getNeighbours&nbsp;(node[, allowDiagonal])</a></td>
	<td class="summary">Returns the neighbours of a given <a href="../modules/core.grid.html#core.node">node</a>  on a grid</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#grid:iter">grid:iter&nbsp;([lx[, ly[, ex[, ey]]]])</a></td>
	<td class="summary">Iterates on nodes on the grid.</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#grid:each">grid:each&nbsp;(f[, ...])</a></td>
	<td class="summary">Each iterator.</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#grid:eachRange">grid:eachRange&nbsp;(lx, ly, ex, ey, f[, ...])</a></td>
	<td class="summary">Each range interator.</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#grid:imap">grid:imap&nbsp;(f[, ...])</a></td>
	<td class="summary">Map iterator.</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#grid:imapRange">grid:imapRange&nbsp;(lx, ly, ex, ey, f[, ...])</a></td>
	<td class="summary">Map range iterator.</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#grid:getNodeAt">grid:getNodeAt&nbsp;(x, y)</a></td>
	<td class="summary">Returns the <a href="../modules/core.grid.html#core.node">node</a> [x,y] on a <a href="../modules/core.grid.html#core.grid">grid</a> .</td>
	</tr>
</table>
<h2><a href="#Tables">Tables</a></h2>
<table class="function_list">
	<tr>
	<td class="name" nowrap><a href="#grid">grid</a></td>
	<td class="summary">The <a href="../modules/core.grid.html#core.grid">grid</a>  class</td>
	</tr>
</table>

<br/>
<br/>


    <h2><a name="Functions"></a>Functions</h2>

    <dl class="function">
    <dt>
    <a name = "grid:new"></a>
    <strong>grid:new&nbsp;(map[, walkable[, processOnDemand]])</strong>
    </dt>
    <dd>
    Inits a new <a href="../modules/core.grid.html#core.grid">grid</a>  object

    <h3>Parameters:</h3>
    <ul>
      <li><span class="parameter">map</span>
        <span class="types"><a class="type" href="http://www.lua.org/manual/5.1/manual.html#5.5">table</a> or <a class="type" href="http://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
       A collision map - (2D array) with consecutive integer indices or a string with line-break symbol as a row delimiter.</li>
      <li><span class="parameter">walkable</span>
        <span class="types"><a class="type" href="http://www.lua.org/manual/5.1/manual.html#5.4">string</a>, <span class="type">int</span> or <span class="type">function</span></span>
       the value for walkable nodes on the passed-in map array.
 If this parameter is a function, it should be prototyped as <code>f(value)</code>, returning a boolean:
 <code>true</code> when value matches a <em>walkable</em> node, <code>false</code> otherwise.</li>
      <li><span class="parameter">processOnDemand</span>
        <span class="types"><span class="type">bool</span></span>
       whether or not caching nodes in the internal grid should be processed on-demand</li>
    </ul>

    <h3>Returns:</h3>
    <ol>

          <span class="types"><a class="type" href="../modules/core.grid.html#core.grid">grid</a></span>
        a new <a href="../modules/core.grid.html#core.grid">grid</a>  object
    </ol>




</dd>
    <dt>
    <a name = "grid:isWalkableAt"></a>
    <strong>grid:isWalkableAt&nbsp;(x, y)</strong>
    </dt>
    <dd>
    Checks walkability.  Tests if <a href="../modules/core.grid.html#core.node">node</a>  [x,y] exists on the collision map and is walkable

    <h3>Parameters:</h3>
    <ul>
      <li><span class="parameter">x</span>
        <span class="types"><span class="type">int</span></span>
       the x-coordinate of the node</li>
      <li><span class="parameter">y</span>
        <span class="types"><span class="type">int</span></span>
       the y-coordinate of the node</li>
    </ul>

    <h3>Returns:</h3>
    <ol>

          <span class="types"><span class="type">bool</span></span>
        <code>true</code> if the node exist and is walkable, <code>false</code> otherwise
    </ol>




</dd>
    <dt>
    <a name = "grid:getNeighbours"></a>
    <strong>grid:getNeighbours&nbsp;(node[, allowDiagonal])</strong>
    </dt>
    <dd>
    Returns the neighbours of a given <a href="../modules/core.grid.html#core.node">node</a>  on a grid

    <h3>Parameters:</h3>
    <ul>
      <li><span class="parameter">node</span>
        <span class="types"><a class="type" href="../modules/core.grid.html#core.node">node</a></span>
       <a href="../modules/core.grid.html#core.node">node</a>  object</li>
      <li><span class="parameter">allowDiagonal</span>
        <span class="types"><span class="type">bool</span></span>
       whether or not 8-directions movements is allowed</li>
    </ul>

    <h3>Returns:</h3>
    <ol>

          <span class="types"><span class="type">{node,...}</span></span>
        an array of nodes neighbouring a passed-in node on the collision map
    </ol>




</dd>
    <dt>
    <a name = "grid:iter"></a>
    <strong>grid:iter&nbsp;([lx[, ly[, ex[, ey]]]])</strong>
    </dt>
    <dd>
    Iterates on nodes on the grid.  When given no args, will iterate on every single node
 on the grid, in case the grid is pre-processed. Passing <code>lx, ly, ex, ey</code> args will iterate
 on nodes inside a bounding-rectangle delimited by those coordinates.

    <h3>Parameters:</h3>
    <ul>
      <li><span class="parameter">lx</span>
        <span class="types"><span class="type">int</span></span>
       the leftmost x-coordinate coordinate of the rectangle</li>
      <li><span class="parameter">ly</span>
        <span class="types"><span class="type">int</span></span>
       the topmost y-coordinate of the rectangle</li>
      <li><span class="parameter">ex</span>
        <span class="types"><span class="type">int</span></span>
       the rightmost x-coordinate of the rectangle</li>
      <li><span class="parameter">ey</span>
        <span class="types"><span class="type">int</span></span>
       the bottom-most y-coordinate of the rectangle</li>
    </ul>

    <h3>Returns:</h3>
    <ol>

          <span class="types"><a class="type" href="../modules/core.grid.html#core.node">node</a></span>
        a node on the collision map, upon each iteration step
    </ol>




</dd>
    <dt>
    <a name = "grid:each"></a>
    <strong>grid:each&nbsp;(f[, ...])</strong>
    </dt>
    <dd>
    Each iterator.  Executes a function on each <a href="../modules/core.grid.html#core.node">node</a>  in the <a href="../modules/core.grid.html#core.grid">grid</a> , passing the <a href="../modules/core.grid.html#core.node">node</a>  as the first arg to function <code>f</code>.

    <h3>Parameters:</h3>
    <ul>
      <li><span class="parameter">f</span>
        <span class="types"><span class="type">function</span></span>
       a function prototyped as <code>f(node,...)</code></li>
      <li><span class="parameter">...</span>
        <span class="types"><span class="type">vararg</span></span>
       args to be passed to function <code>f</code></li>
    </ul>





</dd>
    <dt>
    <a name = "grid:eachRange"></a>
    <strong>grid:eachRange&nbsp;(lx, ly, ex, ey, f[, ...])</strong>
    </dt>
    <dd>
    Each range interator.  Executes a function on each <a href="../modules/core.grid.html#core.node">node</a>  in the range of a rectangle of cells, passing the <a href="../modules/core.grid.html#core.node">node</a>  as the first arg to function <code>f</code>.

    <h3>Parameters:</h3>
    <ul>
      <li><span class="parameter">lx</span>
        <span class="types"><span class="type">int</span></span>
       the leftmost x-coordinate coordinate of the rectangle</li>
      <li><span class="parameter">ly</span>
        <span class="types"><span class="type">int</span></span>
       the topmost y-coordinate of the rectangle</li>
      <li><span class="parameter">ex</span>
        <span class="types"><span class="type">int</span></span>
       the rightmost x-coordinate of the rectangle</li>
      <li><span class="parameter">ey</span>
        <span class="types"><span class="type">int</span></span>
       the bottom-most y-coordinate of the rectangle</li>
      <li><span class="parameter">f</span>
        <span class="types"><span class="type">function</span></span>
       a function prototyped as <code>f(node,...)</code></li>
      <li><span class="parameter">...</span>
        <span class="types"><span class="type">vararg</span></span>
       args to be passed to function <code>f</code></li>
    </ul>





</dd>
    <dt>
    <a name = "grid:imap"></a>
    <strong>grid:imap&nbsp;(f[, ...])</strong>
    </dt>
    <dd>
    Map iterator.  Maps function <code>f(node,...)</code> on each <a href="../modules/core.grid.html#core.node">node</a>  in a given range, passing the <a href="../modules/core.grid.html#core.node">node</a>  as the first arg to function <code>f</code>.

    <h3>Parameters:</h3>
    <ul>
      <li><span class="parameter">f</span>
        <span class="types"><span class="type">function</span></span>
       a function prototyped as <code>f(node,...)</code></li>
      <li><span class="parameter">...</span>
        <span class="types"><span class="type">vararg</span></span>
       args to be passed to function <code>f</code></li>
    </ul>





</dd>
    <dt>
    <a name = "grid:imapRange"></a>
    <strong>grid:imapRange&nbsp;(lx, ly, ex, ey, f[, ...])</strong>
    </dt>
    <dd>
    Map range iterator.  Maps <code>f(node,...)</code> on each <code>nod</code>e in the range of a rectangle of cells, passing the <a href="../modules/core.grid.html#core.node">node</a>  as the first arg to function <code>f</code>.

    <h3>Parameters:</h3>
    <ul>
      <li><span class="parameter">lx</span>
        <span class="types"><span class="type">int</span></span>
       the leftmost x-coordinate coordinate of the rectangle</li>
      <li><span class="parameter">ly</span>
        <span class="types"><span class="type">int</span></span>
       the topmost y-coordinate of the rectangle</li>
      <li><span class="parameter">ex</span>
        <span class="types"><span class="type">int</span></span>
       the rightmost x-coordinate of the rectangle</li>
      <li><span class="parameter">ey</span>
        <span class="types"><span class="type">int</span></span>
       the bottom-most y-coordinate of the rectangle</li>
      <li><span class="parameter">f</span>
        <span class="types"><span class="type">function</span></span>
       a function prototyped as <code>f(node,...)</code></li>
      <li><span class="parameter">...</span>
        <span class="types"><span class="type">vararg</span></span>
       args to be passed to function <code>f</code></li>
    </ul>





</dd>
    <dt>
    <a name = "grid:getNodeAt"></a>
    <strong>grid:getNodeAt&nbsp;(x, y)</strong>
    </dt>
    <dd>
    Returns the <a href="../modules/core.grid.html#core.node">node</a> [x,y] on a <a href="../modules/core.grid.html#core.grid">grid</a> .

    <h3>Parameters:</h3>
    <ul>
      <li><span class="parameter">x</span>
        <span class="types"><span class="type">int</span></span>
       the x-coordinate coordinate</li>
      <li><span class="parameter">y</span>
        <span class="types"><span class="type">int</span></span>
       the y-coordinate coordinate</li>
    </ul>

    <h3>Returns:</h3>
    <ol>

          <span class="types"><a class="type" href="../modules/core.grid.html#core.node">node</a></span>
        a <a href="../modules/core.grid.html#core.node">node</a>  object <br/>
 Gets the node at location <x,y> on a preprocessed grid
    </ol>




</dd>
</dl>
    <h2><a name="Tables"></a>Tables</h2>

    <dl class="function">
    <dt>
    <a name = "grid"></a>
    <strong>grid</strong>
    </dt>
    <dd>
    The <a href="../modules/core.grid.html#core.grid">grid</a>  class

    <h3>Fields:</h3>
    <ul>
      <li><span class="parameter">width</span>
       The grid width</li>
      <li><span class="parameter">height</span>
       The grid height</li>
      <li><span class="parameter">walkable</span>
       The value for walkable nodes</li>
      <li><span class="parameter">map</span>
       A reference to the collision map</li>
      <li><span class="parameter">nodes</span>
       A 2D array of nodes, each node matching a cell on the collision map</li>
    </ul>





</dd>
</dl>


</div> <!-- id="content" -->
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.3</a></i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>
</html>
